<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page import="mickey.*"%>
<%@ page import="java.util.ArrayList"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Mickey Maus Datenbank</title>
</head>
<body>
	<h1>Mickey's Archiv!</h1>
	<jsp:include page="InputForm.jsp"/>
	<%
		DataOperations dop = new DataOperations();
		String name = request.getParameter("name");
		String jahrgang = request.getParameter("jahrgang");
		if (name != null && jahrgang != null) {
			int jahr = Integer.parseInt(jahrgang);
			System.out.println("Name: " + name + " Jahrgang: " + jahr);
			dop.addHeft(name, jahr);
		}
		if (request.getParameter("function") != null
				&& request.getParameter("function").equalsIgnoreCase(
						"delete")) {
			dop.deleteHeft(request.getParameter("name"),
					request.getParameter("jahr"));
		}

		ArrayList<MickeyMausHeft> mm = dop.getAll();
		System.out.println(mm.size());
	%>
	<br />
	<h2>Bisher eingetragene Hefte:</h2>
	<%
		for (int i = 0; i < mm.size(); i++) {
	%>
	<%
		out.println(mm.get(i).getJahr() + " " + mm.get(i).getName());
	%>
	<a href="index.jsp?function=delete&name=<%=mm.get(i).getName()%>&jahr=<%=mm.get(i).getJahr()%>">Delete</a>
	<br />
	<%
		}
	%>
</body>
</html>